/*This file is part of PaperBall.

PaperBall is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

PaperBall is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with PaperBall.  If not, see <http://www.gnu.org/licenses/>.*/

package com.ran3000.paperball;

import java.util.Random;

import com.ran3000.paperball.framework.DynamicBallObject;

public class Bomb extends DynamicBallObject {
	public static final float BOMB_RADIUS = 0.75f;
	public static final float BOMB_SCORE = 1;
	public static final int BOMB_EXPLODED = 0;
	public static final int BOMB_NONEXPLODED = 1;
	
	float fallVelocity = 1;
	float stateTime;
	int state;
	Random rand;
	
	public Bomb(float x, float y) {
		super(x, y, BOMB_RADIUS);
		stateTime = 0;
		state = BOMB_NONEXPLODED;
		rand = new Random();
	}
	
	public void update(float deltaTime) {
		fallVelocity = rand.nextFloat() * (2 - 0.3f) + 0.3f;
		velocity.add(0, World.gravity.y * deltaTime * fallVelocity);
		position.add(0, velocity.y * deltaTime);
		bounds.center.set(position);
		
		stateTime += deltaTime;
		
		if(position.y <= 1.3f) {
			state = BOMB_EXPLODED;
			velocity.set(0, 0);
		}
	}
}
